package com.youshang520i.springcommonmiddleware;

import com.fasterxml.jackson.databind.ObjectMapper;
import org.springframework.amqp.support.converter.Jackson2JsonMessageConverter;
import org.springframework.amqp.support.converter.MessageConverter;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.SpringBootConfiguration;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Bean;
import org.springframework.scheduling.annotation.EnableScheduling;

/**
 * @author youshang
 */
@EnableScheduling
@SpringBootApplication
public class SpringCommonMiddleware {

    public static void main(String[] args) {
        SpringApplication.run(SpringCommonMiddleware.class,args);
    }


    /**
     *  https://blog.csdn.net/qq_36497454/article/details/92749740
     * @param objectMapper
     * @return
     */
    @Bean
    public MessageConverter jsonMessageConverter(ObjectMapper objectMapper) {
        return new Jackson2JsonMessageConverter(objectMapper);
    }

    //重点： Value 不会起到针对Consul动态加载配置文件的作用
//    @Value("${spring.rabbitmq.host}")
//    public String env1;
//
//    @PostConstruct
//    public void init(){
//        System.out.println("env1:  " + env1);
//    }

}
